﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using ChessWebService.DTO;
using ChessWebService.Models;

namespace ChessWebService.Controllers
{
    public class TaiKhoanController : ApiController
    {
        //Kiem tra dang nhap.
        public TaiKhoan Get(string username, string password)
        {
            TaiKhoanDAO TaiKhoanDAO = new TaiKhoanDAO();
            TaiKhoan TaiKhoan = new TaiKhoan();
            TaiKhoan.UserName = username;
            TaiKhoan.Password = password;
            return TaiKhoanDAO.KiemTraTaiKhoan(TaiKhoan);
        }

        public void Post([FromBody]TaiKhoan value)
        {
            TaiKhoanDAO TaiKhoanDAO = new TaiKhoanDAO();
            TaiKhoanDAO.ThemTaiKhoan(value);
        }

        //Kiem tra username ton tai.
        public TaiKhoan Get(String UserName)
        {
            TaiKhoanDAO TaiKhoanDAO = new TaiKhoanDAO();
            TaiKhoan info = TaiKhoanDAO.KiemTraTaiKhoan(UserName);
            return info;
        }

        public void Put([FromBody]TaiKhoan value)
        {
            TaiKhoanDAO TaiKhoanDAO = new TaiKhoanDAO();
            TaiKhoanDAO.CapNhatTaiKhoan(value);
        }
    }
}
